home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
database
/
flexbase.exe
/
CHAP8.TXT
< prev
next >
Wrap
Text File
|
1987-07-11
|
8KB
|
99 lines
SORTING AN INDEXED DATABASE
This chapter describes how to sort (physically reorder) the data in the
database using the FBS module.
Flexbase uses key files to maintain an ascending/descending order of
the records in the database. As records are added to the database, they
are appended to the end of the database file. This means that the physical
order of the records in the database follows the order that the records
were entered.
As each record is entered, the key fields are added to their respective
key files along with a pointer that identifies the position of the record
in the database. This allows you to access the records in an ascending or
descending order using the previous and next (F7 and F8) keys.
When printing a report, using the Flexbase report generation system,
you are allowed to specify which key field in the database you would like
to order the display of records in the report. Or, you can elect to print
the records based on their physical order in the database (unsorted).
For reports that use only one key field (or none) to order the display
of the report, the current physical record order of the database does not
have to be altered. Each record can be obtained in the proper order using
the record pointers in the key file.
When the need arises to print a report with the order based on several
key fields, with each key field printed in either ascending or descending
order, the Flexbase Sort module must be executed. The Sort module (FBS)
allows you to physically reorder the records in the database so that the
desired result can be obtained when the report is printed.
As an example, if you maintained a database that consisted of client
names, addresses, phone numbers, etc., you may desire to print a report
which displays the records in the following order:
1. Zip Code (ascending)
2. City (ascending)
3. Name (ascending)
When the report is printed, the zip codes would be displayed in
ascending order. Within each zip code, an ascending list of cities would
be displayed and within each city, an ascending list of names would be
displayed.
You can sort the records in the database on as many key fields as you
desire.
EXECUTING FBS
If you are using a two diskette system, place the Flexbase System
diskette (Number 2), into drive A and the diskette with the database to be
sorted into drive B. At the DOS command line type FBS and press Enter.
When the Sort screen appears, the cursor will be positioned within the
filename box at the bottom of the screen, waiting for you to input the name
of the database to be sorted. Enter the name of the database and press
Enter. Two diskette system users must prefix the name of the database with
the drive identifier B:. If the file exist, the Sort table will be loaded
with the names of each key field in the database. Use the cursor control
keys to locate the desired key field and then specify the desired sort
level or display order.
The sort level is a number in the range from one (1) to the maximum
number of key fields used in this database. If you enter a number outside
of the allowable range, the number will be changed to the first available
level. As in the example above, the zip code field would be level 1, the
city field would be assigned level 2 and the name field would be level 3.
As each level is entered for the desired key field, the default order is
set to A for ascending. This can be changed by moving the reverse video
cursor to the order column, locating the desired field and typing D for
descending.
Previously existing sort levels and orders can be deleted from the
Sort table by moving the reverse video cursor to the desired position in
the table and pressing the Del key. As a sort level or order is deleted
from the table, the remaining levels are renumbered automatically.
When you have completed entering the desired information into the Sort
table, press the F9 function key to begin the sorting process. The time
required to sort the database depends on the size of the database, the
number of key fields entered into the Sort table, and the execution speed
of your computer.
When printing a report with a newly sorted database, do not set a sort
order with the F2-S-S option within the report generation system. Since
you have just positioned the records in the database to the desired order,
setting a sort condition inside of the report generation system may alter
the desired display. A newly sorted database can be printed using the
F2-S-S option if the desired display is based on the ascending or
descending order of only one key field.
As new records are added to the database, this module will have to be
executed to physically reorder the database prior to printing another
multi-level report, if desired.